﻿using System;
using System.Collections.Generic;
using NHibernate;
using OpenGado.DATA;
using OpenGado.DATA.Entities;

namespace OpenGado.DATA
{
    public class Session
    {

        public void OpenSession()
        {

            using (ISession session = FactoryHandler.CreateFactory().OpenSession())
            {
                Project project = new Project();
                project.Code = "1003KE";
                project.Name = "Ass Kissing";
                project.Coordinator = "dkowuor";
                project.StartingDate = DateTime.Now; //everyday is today ;)
            
              
                Categories cat  = new Categories("General stuff");
               
                Product product = new Product();
                product.BatchNumber = " 12345";
                product.ProductName = "Lotion";
                product.ProductDescription = "smothie";
                product.Categories = cat;

              ProjectHasProduct prod  =new ProjectHasProduct();
                prod.Product = product;
                prod.ProductQuantity = 300;
                prod.Project = project;
               

               // session.SaveOrUpdate(project);
                session.SaveOrUpdate(cat);
               // session.SaveOrUpdate(product);
                session.SaveOrUpdate(prod);
                


                  session.Close();
            }


        }
    }

}
